<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class LeaderProfile.
 * @property int sort
 */
class LeaderProfile extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $guarded = [];

    public function getPhotoAttribute($value)
    {
        if (substr($value, 0, 4) != 'http') {
            return config('app.url') . $value;
        }
        return $value;
    }

    /**
     * 为数组 / JSON 序列化准备日期。
     *
     * @return string
     */
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }
}
